<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>赛事</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/binge.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/swiper.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>

    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
    <style type="text/css">

        .match_nav{
            height: 0.8rem;
            background-color: #ffffff;
            box-shadow: 0 0 0.08rem 0 rgba(0, 0, 0, 0.03);
            /*padding: 0 0.3rem;*/
        }

        .match_nav .swiper-container{
            width: 360px;
            margin: 0 auto;
        }
        .match_nav li{height: .71rem;line-height: .71rem;position: relative;font-size: 0.26rem; text-align: center; color:#666;}
        .match_nav li span{
            display: inline-block;
            position: relative;
            height: 0.71rem;
        }
        .match_nav li span:before{content:"";width: 0;transition: width 0.3s;}
        .match_nav li.on span{color:#ff7777;transition: 0.3s; font-weight: bold;}
        .match_nav li.on span:before{content:"";position: absolute;width: 100%;bottom:0.01rem;left:0; display: block;height: 0.04rem;background-image: linear-gradient(
                #ff7777,
                #ff7777),
        linear-gradient(
                #000000,
                #000000);
            background-blend-mode: normal,
            normal;
            border-radius: 0.02rem;}

        .main-match{
            height: calc(100vh - 1.4rem);
        }
        .main-match .swiper-wrapper,
        .main-match .swiper-slide{
            height: 100%;
        }
        .mescroll{
            height: 100%;
        }
    </style>
</head>

<body>
<div id="header" style="height: 1.66rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 99">
    <div class="match_top">
        <div class="flex_center pt20 pb15" style="box-shadow: 0rem 0rem 0.08rem 0rem rgba(0, 0, 0, 0.03);">
            <div class="match_top_type on" tapmode>看点</div>
            <div class="match_top_type" tapmode onclick="UrlNoAnimation('match_index_data')">数据</div>
        </div>
        <div class="match_nav">
            <div class="swiper-container" id="tabList">
                <ul class="match_nav_li swiper-wrapper" id="match_nav">
                    <li class="swiper-slide on"><span>全部信息</span></li>
                    <li class="swiper-slide"><span>我的关注</span></li>
                    <li class="swiper-slide"><span>公开课</span></li>
                    <li class="swiper-slide"><span>空中宣讲</span></li>
                    <li class="swiper-slide"><span>CUBA男</span></li>
                    <li class="swiper-slide"><span>CUFA(超冠)</span></li>
                    <li class="swiper-slide"><span>CUFA(超冠)</span></li>
                </ul>
            </div>
        </div>

    </div>

</div>
<div class="swiper-container main-match" id="mainMatch" style="padding-top: 2.5rem;background: #f5f5f5;">
    <div class="swiper-wrapper" id="mainMatchChild">
        <div class="swiper-slide" data-uflag="true" data-dflag="true" data-uppage="1" data-downpage="1">
            <div class="mescroll" id="mescroll0">
                <ul class="match_list1 getlist">

                </ul>
            </div>
        </div>

    </div>


</div>



<div id="footer" class="border-t">
    <ul class="flex-wrap">
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">首页</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">圈子</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">
            <div class="school-logo">
                <img id="school_path" src="" alt="">
            </div>
        </li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con active">在看</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">我的</li>
    </ul>
</div>

<div class="fixed-btn" style="bottom: 2rem;">
    <a href="javascript:void(0);" tapmode onclick="loadPage()" class="reload-view"></a>
</div>

</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/mescroll.min.css"/>
<script type="text/javascript" src="../../script/mescroll.min.js"></script>

<script type="text/javascript" src="../../script/matchMescroll.js"></script>
<script type="text/javascript">
    var firstType = 1;//类型：1比赛 2数据
    var secondType = 1;//类型：1今天 2今天以前 3今天以后
    var category_id = 153;//分类id
    var pageDown = 1;
    var pageUp = 1;
    var pullUp = true;
    var pullDown = false;
    var sType = false;

    apiready = function () {
        setFixStatusBar(); //设置状态栏
        pop.loading();

        api.addEventListener({
            name: 'remind'
        }, function (ret, err) {
            getMatchIndex(secondType);
        });

        $('#school_path').attr('src', $api.getStorage('schoolPath'));

        api.addEventListener({
            name: 'schoolPathStatus'
        }, function (ret, err) {
            $('#school_path').attr('src', $api.getStorage('schoolPath'));
        });

        getMatchNav();

        getMatchIndex(1);


        isIosX()

        ExitApp()

    }

    var NavArr = [];
    var lastIndex = 0;
    var navIndex = 0;
    var swiper2 = new Swiper('#tabList',{
        watchSlidesProgress : true,
        watchSlidesVisibility : true,
        slidesPerView : 4,
        observer:true,
        observeParents:true,
        freeMode : true,
        freeModeSticky : true,
        onTap: function(){
            var _this = $('#tabList .swiper-slide').removeClass('on').eq(swiper2.clickedIndex).addClass('on');
            swiper3.slideTo( swiper2.clickedIndex,0,false)
            lastIndex = swiper2.clickedIndex;
            changeNav(_this)
        },
        onInit: function () {
            $('#tabList .swiper-slide').eq(0).addClass('on');
        }
    })
    var swiper3 = new Swiper('#mainMatch',{
        observer:true,
        observeParents:true,
        spaceBetween: 25,
        autoHeight: true, //高度随内容变化
        followFinger: false,
        onSlideChangeStart: function(swiper){
            updateNavPosition(swiper.activeIndex)
        },

    })
    function updateNavPosition(activeIndex){

        $('#tabList .swiper-slide').removeClass('on')
        var activeNav = $('#tabList .swiper-slide').eq(swiper3.activeIndex).addClass('on');
        if (!activeNav.hasClass('swiper-slide-visible')) {
            if (activeNav.index()>swiper2.activeIndex) {
                var thumbsPerNav = Math.round(swiper2.width/activeNav.width())-1;
                swiper2.slideTo(activeNav.index()-thumbsPerNav)
                changeNav(activeNav)
            } else {
                swiper2.slideTo(activeNav.index())
                changeNav(activeNav)
            }
        }else {
            changeNav(activeNav)
        }
    }

    function changeNav(that) {
        var _this = $(that);
        // console.log(_this)
        if(_this.index() == navIndex){
            return;
        }
        navIndex = _this.index();
        console.log(navIndex)
        var id = _this.attr('data-id');
        var _currNav = $('#mainMatchChild .swiper-slide').eq(navIndex);
        _currNav.attr('data-uflag',true);
        _currNav.attr('data-dflag',true);
        _currNav.attr('data-uppage',1);
        _currNav.attr('data-downpage',1);
        pageDown = 1;
        pageUp = 1;
        pullUp = true;
        pullDown = false;
        category_id = id;
        console.log(category_id)
        _this.addClass('on').siblings('li').removeClass('on');


        getMatchIndex(1,'down')

    }


    //刷新页面
    function loadPage() {
        var _currNav = $('#mainMatchChild .swiper-slide').eq(navIndex);
        _currNav.attr('data-uflag',true);
        _currNav.attr('data-dflag',true);
        _currNav.attr('data-uppage',1);
        _currNav.attr('data-downpage',1);
        pageDown = 1;
        pageUp = 1;
        pullUp = true;
        pullDown = false;
        getMatchIndex(1);
        $('.mescroll').animate({scrollTop:0},10);//回到顶端
    }


    function getMatchNav() {
        var param = {
            token: $api.getStorage('token'),
            type: firstType,//类型：1比赛 2数据
        }
        getAjax(Interface.get_nave, param, function (res) {

            var data = res.data;

            if (isDefine(data)) {
                var navHtml = '';
                var section_li = '';
                for (var i = 0; i < data.length; i++) {
                    var ii = i+1;
                    var titval = {"index":i,"scroll_num":0,'flag': true,'uppage': 1,'dowmpage': 1};
                    NavArr.push(titval);

                    var info = data[i];
                    if (i == 0) {
                        navHtml += '<li tapmode class="on swiper-slide" data-id="' + info.id + '"><span>' + info.title + '</span></li>';
                        category_id = info.id;
                    } else {
                        navHtml += '<li tapmode class="swiper-slide" data-id="' + info.id + '"><span>' + info.title + '</span></li>';
                    }
                    if (i < (data.length - 1)) {
                        section_li += '<div class="swiper-slide" data-uflag="true" data-dflag="true" data-uppage="1" data-downpage="1"><div class="mescroll" id="mescroll'+ii+'"><ul class="match_list1 getlist"></ul></div></div>'
                    }
                }
                console.log(jsonChange(NavArr))

                $("#match_nav").html(navHtml)
                $("#mainMatchChild").append(section_li);
                // console.log($("#mainMatchChild").html())

                loadMescroll();

            }
            pop.close();
        }, function (error) {
            pop.notice(error.msg);
            pop.close();
        })
    }


    var flagNumId = 50;

    var tipsNum = 0;
    function getMatchIndex(status,upDown) {
        var _currNav = $('#mainMatchChild .swiper-slide').eq(navIndex);
        pullUp = _currNav.attr('data-uflag');
        pullDown = _currNav.attr('data-dflag');
        pageUp = _currNav.attr('data-uppage');
        pageDown = _currNav.attr('data-downpage');
        console.log(navIndex);
        console.log(pageDown);
        console.log('uflag:'+pullUp+',dflag:'+pullDown+',uppage:'+pageUp+',downpage:'+pageDown);
        if(status == 1){
            secondType = 1;
        }else if(status == 2){
            secondType = 2;
        }else if(status == 3){
            secondType = 3;
        }
        var page = 1;
        if (upDown == 'up') {
            page = pageUp
        } else if(upDown == 'down'){
            page = pageDown
        }
        var param = {
            token: $api.getStorage('token'),
            category_id: category_id,//分类id
            type: secondType,//类型：1今天 2今天以前 3今天以后
            page: page,
        }
        getAjax(Interface.match_index2, param, function (res) {
            // pullDown = false;
            // console.log(jsonChange(res))

            var data = res.data.list;
            //stype 1是对抗赛，2是团队赛
            //type 1是篮球，2是足球
            //status 1是未开始，2是进行中，3是已结束
            if (isDefine(data)) {
                // console.log('有数据有数据有数据有数据有数据有数据有数据有数据有数据有数据有数据有数据有数据')
                var matchHtml = '';
                var flag = '';
                var num = 0;
                var numLen = data.length;
                $.each(data, function (i, item) {

                    num++;
                    if(num == numLen){
                        flag = 'id'+navIndex+flagNumId;
                        flagNumId++;
                    }
                    var numChild = 0;
                    if (isDefine(item.data)) {
                        var numChildLen = item.data.length;

                        if(secondType == 2){

                            matchHtml += '<li class="pt10 pb10 f24 c-999 pl50 ">' + item.date_time + '</li>'

                            $.each(item.data, function (j, jtem) {
                                var childId = '';
                                numChild++;
                                if(numChild == numChildLen){
                                    childId = flag;
                                }
                                if (jtem.stype == 1) {
                                    //stype 1是对抗赛，2是团队赛
                                    if (jtem.type == 1) {
                                        //type 1是篮球，2是足球
                                        var statusHtml = '';
                                        if (jtem.status == 1) {
                                            //status 1是未开始，2是进行中，3是已结束,4是直播中 带url  5是集锦
                                            var bellHtml = '';
                                            if (jtem.remind_status == 2) {
                                                bellHtml = ' <div class="bell" tapmode onclick=\'remind(' + jtem.id + ',this,event)\'>' +
                                                    '                    <img class="icon-bell bell-off" src="../../icon/icon-bell.png"/>' +
                                                    '                    <img class="icon-bell bell-on" src="../../icon/icon-bell-on.png"/>' +
                                                    '          </div>'
                                            } else {
                                                bellHtml = ' <div class="bell on" tapmode onclick=\'remind(' + jtem.id + ',this,event)\'>' +
                                                    '               <img class="icon-bell bell-off" src="../../icon/icon-bell.png"/>' +
                                                    '               <img class="icon-bell bell-on" src="../../icon/icon-bell-on.png"/>' +
                                                    '       </div>'
                                            }

                                            statusHtml = '<div class="mt10 match_score">' + bellHtml + '</div>' +
                                                '         <div class="match_tips1 end mt10 c-fff"><i class="icon-live mr10"></i>未开始</div>';


                                        } else if (jtem.status == 2) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">' + jtem.data[0].branch + ' - ' +jtem.data[1].branch+ '</div>' +
                                                '         <div class="match_tips1 being mt10 c-fff">进行中</div>';
                                        } else if (jtem.status == 3){
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">' + jtem.data[0].branch + ' - ' +jtem.data[1].branch+ '</div>' +
                                                '         <div class="match_tips1 end mt10 c-fff">已结束</div>';
                                        } else if (jtem.status == 4){
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">' + jtem.data[0].branch + ' - ' +jtem.data[1].branch+ '</div>' +
                                                '         <div class="match_tips1 being mt10 c-fff"><i class="icon-live mr10"></i>直播中</div>';
                                        } else if (jtem.status == 5){
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">' + jtem.data[0].branch + ' - ' +jtem.data[1].branch+ '</div>' +
                                                '         <div class="match_tips1 being mt10 c-fff"><i class="icon-live mr10"></i>视频回放</div>';
                                        }
                                        var teamParam1 = {"team_id": jtem.data[0].team_id};//左侧队伍id
                                        var teamParam2 = {"team_id": jtem.data[1].team_id};//右侧队伍id
                                        var matchParam = {"match_id": jtem.id};//比赛id


                                        matchHtml += '<li id="'+childId+'" class="match_li flex_center ">' +
                                            '            <div class="match_team f26 pt30" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                                            '                <div class="match_team_img bg-cover" style="background: url(' + ajaxUrl + jtem.data[0].team_path + ') center no-repeat;"></div>' +
                                            '                <div class="mt20 pd10 t-c">' + jtem.data[0].team_title + '</div>' +
                                            '            </div>' +
                                            '            <div class="match_details" tapmode onclick=\'commonUrl("match_basketball",' + jsonChange(matchParam) + ')\'>' +
                                            '                <div class="b f32">' + jtem.title + '</div>' +
                                            '                <div class="mt10 c-999 f24">' + jtem.start_date + ' ' + jtem.address + '</div>' + statusHtml +
                                            '            </div>' +
                                            '            <div class="match_team f26 pt30" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                                            '                <div class="match_team_img bg-cover" style="background: url(' + ajaxUrl + jtem.data[1].team_path + ') center no-repeat;"></div>' +
                                            '                <div class="mt20 pd10 t-c">' + jtem.data[1].team_title + '</div>' +
                                            '            </div>' +
                                            '        </li>';


                                    } else {

                                        //type 1是篮球，2是足球
                                        var statusHtml = '';
                                        if (jtem.status == 1) {
                                            //status 1是未开始，2是进行中，3是已结束,4是直播中 带url  5是集锦

                                            var bellHtml = '';
                                            if (jtem.remind_status == 2) {
                                                bellHtml = ' <div class="bell" tapmode onclick=\'remind(' + jtem.id + ',this,event)\'>' +
                                                    '                    <img class="icon-bell bell-off" src="../../icon/icon-bell.png"/>' +
                                                    '                    <img class="icon-bell bell-on" src="../../icon/icon-bell-on.png"/>' +
                                                    '          </div>'
                                            } else {
                                                bellHtml = ' <div class="bell on" tapmode onclick=\'remind(' + jtem.id + ',this,event)\'>' +
                                                    '               <img class="icon-bell bell-off" src="../../icon/icon-bell.png"/>' +
                                                    '               <img class="icon-bell bell-on" src="../../icon/icon-bell-on.png"/>' +
                                                    '       </div>'
                                            }

                                            statusHtml = '<div class="mt10 match_score" style="width: 1.3rem;margin-left: 0.2rem;">' + bellHtml + '</div>' +
                                                '         <div class="match_tips1 end mt10 c-fff"><i class="icon-live mr10"></i>未开始</div>';


                                        } else if (jtem.status == 2) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">'+jtem.data[0].branch+' - '+jtem.data[1].branch+'</div>' +
                                                '         <div class="match_tips1 being mt10 c-fff">进行中</div>';
                                        } else if (jtem.status == 3) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">'+jtem.data[0].branch+' - '+jtem.data[1].branch+'</div>' +
                                                '         <div class="match_tips1 end mt10 c-fff">已结束</div>';

                                        } else if (jtem.status == 4) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">'+jtem.data[0].branch+' - '+jtem.data[1].branch+'</div>' +
                                                '         <div class="match_tips1 being mt10 c-fff"><i class="icon-live mr10"></i>直播中</div>';

                                        } else if (jtem.status == 5) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">'+jtem.data[0].branch+' - '+jtem.data[1].branch+'</div>' +
                                                '         <div class="match_tips1 being mt10 c-fff"><i class="icon-live mr10"></i>视频回放</div>';

                                        }

                                        var team_one = '';
                                        if (isDefine(jtem.data[0].node)) {
                                            for (var aa = 0; aa < jtem.data[0].node.length; aa++) {
                                                var nodeP = 'node' + jtem.data[0].node[aa].type;
                                                team_one += '<div class="mt10 f22 line_center c-999"><span class="name single-ellipsis">' + jtem.data[0].node[aa].player_name + '</span><span class="node ' + nodeP + ' ml10"></span></div>'
                                            }
                                        }
                                        var team_two = '';
                                        if (isDefine(jtem.data[1].node)) {
                                            for (var aa = 0; aa < jtem.data[1].node.length; aa++) {
                                                var nodeP = 'node' + jtem.data[1].node[aa].type;
                                                team_two += '<div class="mt10 f22 line_center c-999"><span class="node ' + nodeP + ' mr10"></span><span class="name single-ellipsis">' + jtem.data[1].node[aa].player_name + '</span></div>'
                                            }
                                        }
                                        var teamParam1 = {"team_id": jtem.data[0].team_id};//左侧队伍id
                                        var teamParam2 = {"team_id": jtem.data[1].team_id};//右侧队伍id
                                        var matchParam = {"match_id": jtem.id};//比赛id
                                        matchHtml += '<li id="'+childId+'" class="match_li flex_center ">' +
                                            '            <div class="match_team f26 pt30" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                                            '                <div class="match_team_img bg-cover"' +
                                            '                     style="background: url(' + ajaxUrl + jtem.data[0].team_path + ') center no-repeat;"></div>' +
                                            '                <div class="mt20 pd10 t-c">' + jtem.data[0].team_title + '</div>' + team_one +
                                            '            </div>' +
                                            '            <div class="match_details" tapmode onclick=\'commonUrl("match_football",' + jsonChange(matchParam) + ')\'>' +
                                            '                <div class="b f32">' + jtem.title + '</div>' +
                                            '                <div class="mt10 c-999 f24">' + jtem.start_date + ' ' + jtem.address + '</div>' + statusHtml +
                                            '            </div>' +
                                            '            <div class="match_team f26 pt30" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                                            '                <div class="match_team_img bg-cover"' +
                                            '                     style="background: url(' + ajaxUrl + jtem.data[1].team_path + ') center no-repeat;"></div>' +
                                            '                <div class="mt20 pd10 t-c">' + jtem.data[1].team_title + '</div>' + team_two +
                                            '            </div>' +
                                            '        </li>';

                                    }

                                } else {

                                    var statusHtml = '';

                                    if (jtem.status == 1) {
                                        //status 1是未开始，2是进行中，3是已结束
                                        var bellHtml = '';

                                        if (jtem.remind_status == 2) {
                                            bellHtml = ' <div class="bell-status f26" tapmode onclick=\'remind(' + jtem.id + ',this,event)\'>' +
                                                '                    <img class="icon-bell bell-off" src="../../icon/icon-bell.png"/>' +
                                                '                    <img class="icon-bell bell-on" src="../../icon/icon-bell-on.png"/>' +
                                                '          </div>'
                                        } else {
                                            bellHtml = ' <div class="bell-status on f26" tapmode onclick=\'remind(' + jtem.id + ',this,event)\'>' +
                                                '                    <img class="icon-bell bell-off" src="../../icon/icon-bell.png"/>' +
                                                '                    <img class="icon-bell bell-on" src="../../icon/icon-bell-on.png"/>' +
                                                '          </div>'
                                        }

                                        statusHtml = '<div class="match_team" style="width: 1.3rem;margin-left: 0.2rem;">' + bellHtml +
                                            '                    <div class="match_tips1 end mt10 c-fff"><i class="icon-live mr10"></i>未开始</div>' +
                                            '                </div>'


                                    } else if (jtem.status == 2) {
                                        statusHtml = '<div class="match_tips1 being mt10 c-fff ml20">进行中</div>';

                                    } else if (jtem.status == 3) {
                                        statusHtml = '<div class="match_tips1 end mt10 c-fff ml20">已结束</div>';

                                    } else if (jtem.status == 4) {
                                        statusHtml = '<div class="match_tips1 being mt10 c-fff ml20"><i class="icon-live mr10"></i>直播中</div>';

                                    } else if (jtem.status == 5) {
                                        statusHtml = '<div class="match_tips1 being mt10 c-fff ml20"><i class="icon-live mr10"></i>视频回放</div>';

                                    }


                                    var matchParam = {"match_id": jtem.id}
                                    matchHtml += '<li id="'+childId+'" class="match_li line_center" style="padding: 0.1rem 0.1rem;" tapmode onclick=\'commonUrl("team_match_detail",' + jsonChange(matchParam) + ')\'>' +
                                        '            <div class="match_team f26" style="width: calc((100% - 4rem) / 2);">' +
                                        '                <div class="match_team_img bg-cover"' +
                                        '                     style="background: url(' + ajaxUrl + jtem.icon_path + ') center no-repeat;"></div>' +
                                        '            </div>' +
                                        '            <div class="match_details" style="width: 4rem;">' +
                                        '                <div class="b f32" style="width: 100%;">' + jtem.title + '</div>' +
                                        '                <div class="mt10 c-999 f24 t-l"  style="width: 100%;">' + jtem.start_date + ' ' + jtem.address + '</div>' +
                                        '            </div>' + statusHtml +
                                        '        </li>'

                                }

                            })


                        }else{
                            matchHtml += '<li class="pt10 pb10 f24 c-999 pl50 ">' + item.date_time + '</li>'

                            $.each(item.data, function (j, jtem) {

                                var childId = '';
                                numChild++;
                                if(numChild == numChildLen){
                                    childId = flag;
                                }

                                if (jtem.stype == 1) {
                                    //stype 1是对抗赛，2是团队赛
                                    if (jtem.type == 1) {
                                        //type 1是篮球，2是足球
                                        var statusHtml = '';
                                        if (jtem.status == 1) {
                                            //status 1是未开始，2是进行中，3是已结束
                                            var bellHtml = '';
                                            if (jtem.remind_status == 2) {
                                                bellHtml = ' <div class="bell" tapmode onclick=\'remind(' + jtem.id + ',this,event)\'>' +
                                                    '                    <img class="icon-bell bell-off" src="../../icon/icon-bell.png"/>' +
                                                    '                    <img class="icon-bell bell-on" src="../../icon/icon-bell-on.png"/>' +
                                                    '          </div>'
                                            } else {
                                                bellHtml = ' <div class="bell on" tapmode onclick=\'remind(' + jtem.id + ',this,event)\'>' +
                                                    '               <img class="icon-bell bell-off" src="../../icon/icon-bell.png"/>' +
                                                    '               <img class="icon-bell bell-on" src="../../icon/icon-bell-on.png"/>' +
                                                    '       </div>'
                                            }

                                            statusHtml = '<div class="mt10 match_score" style="width: 1.3rem;margin-left: 0.2rem;">' + bellHtml + '</div>' +
                                                '         <div class="match_tips1 end mt10 c-fff"><i class="icon-live mr10"></i>未开始</div>';


                                        } else if (jtem.status == 2) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">' + jtem.data[0].branch + ' - ' +jtem.data[1].branch+ '</div>' +
                                                '         <div class="match_tips1 being mt10 c-fff">进行中</div>';
                                        } else if (jtem.status == 3) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">'+jtem.data[0].branch+' - '+jtem.data[1].branch+'</div>' +
                                                '         <div class="match_tips1 end mt10 c-fff">已结束</div>';

                                        } else if (jtem.status == 4) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">'+jtem.data[0].branch+' - '+jtem.data[1].branch+'</div>' +
                                                '         <div class="match_tips1 being mt10 c-fff"><i class="icon-live mr10"></i>直播中</div>';

                                        } else if (jtem.status == 5) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">'+jtem.data[0].branch+' - '+jtem.data[1].branch+'</div>' +
                                                '         <div class="match_tips1 being mt10 c-fff"><i class="icon-live mr10"></i>视频回放</div>';

                                        }

                                        var teamParam1 = {"team_id": jtem.data[0].team_id};//左侧队伍id
                                        var teamParam2 = {"team_id": jtem.data[1].team_id};//右侧队伍id
                                        var matchParam = {"match_id": jtem.id};//比赛id
                                        matchHtml += '<li id="'+childId+'" class="match_li flex_center ">' +
                                            '            <div class="match_team f26 pt30" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                                            '                <div class="match_team_img bg-cover" style="background: url(' + ajaxUrl + jtem.data[0].team_path + ') center no-repeat;"></div>' +
                                            '                <div class="mt20 pd10 t-c">' + jtem.data[0].team_title + '</div>' +
                                            '            </div>' +
                                            '            <div class="match_details" tapmode onclick=\'commonUrl("match_basketball",' + jsonChange(matchParam) + ')\'>' +
                                            '                <div class="b f32">' + jtem.title + '</div>' +
                                            '                <div class="mt10 c-999 f24">' + jtem.start_date + ' ' + jtem.address + '</div>' + statusHtml +
                                            '            </div>' +
                                            '            <div class="match_team f26 pt30" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                                            '                <div class="match_team_img bg-cover" style="background: url(' + ajaxUrl + jtem.data[1].team_path + ') center no-repeat;"></div>' +
                                            '                <div class="mt20 pd10 t-c">' + jtem.data[1].team_title + '</div>' +
                                            '            </div>' +
                                            '        </li>';


                                    } else {

                                        //type 1是篮球，2是足球
                                        var statusHtml = '';
                                        if (jtem.status == 1) {
                                            //status 1是未开始，2是进行中，3是已结束

                                            var bellHtml = '';
                                            if (jtem.remind_status == 2) {
                                                bellHtml = ' <div class="bell" tapmode onclick=\'remind(' + jtem.id + ',this,event)\'>' +
                                                    '                    <img class="icon-bell bell-off" src="../../icon/icon-bell.png"/>' +
                                                    '                    <img class="icon-bell bell-on" src="../../icon/icon-bell-on.png"/>' +
                                                    '          </div>'
                                            } else {
                                                bellHtml = ' <div class="bell on" tapmode onclick=\'remind(' + jtem.id + ',this,event)\'>' +
                                                    '               <img class="icon-bell bell-off" src="../../icon/icon-bell.png"/>' +
                                                    '               <img class="icon-bell bell-on" src="../../icon/icon-bell-on.png"/>' +
                                                    '       </div>'
                                            }

                                            statusHtml = '<div class="mt10 match_score" style="width: 1.3rem;margin-left: 0.2rem;">' + bellHtml + '</div>' +
                                                '         <div class="match_tips1 end mt10 c-fff"><i class="icon-live mr10"></i>未开始</div>';


                                        } else if (jtem.status == 2) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">'+jtem.data[0].branch+' - '+jtem.data[1].branch+'</div>' +
                                                '         <div class="match_tips1 being mt10 c-fff">进行中</div>';
                                        } else if (jtem.status == 3) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">'+jtem.data[0].branch+' - '+jtem.data[1].branch+'</div>' +
                                                '         <div class="match_tips1 end mt10 c-fff">已结束</div>';

                                        } else if (jtem.status == 4) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">'+jtem.data[0].branch+' - '+jtem.data[1].branch+'</div>' +
                                                '         <div class="match_tips1 being mt10 c-fff"><i class="icon-live mr10"></i>直播中</div>';

                                        } else if (jtem.status == 5) {
                                            if (jtem.data[0].branch == '') {
                                                jtem.data[0].branch = 0;
                                            }
                                            if (jtem.data[1].branch == '') {
                                                jtem.data[1].branch = 0;
                                            }
                                            statusHtml = '<div class="mt10 match_score">'+jtem.data[0].branch+' - '+jtem.data[1].branch+'</div>' +
                                                '         <div class="match_tips1 being mt10 c-fff"><i class="icon-live mr10"></i>视频回放</div>';

                                        }

                                        var team_one = '';
                                        if (isDefine(jtem.data[0].node)) {
                                            for (var aa = 0; aa < jtem.data[0].node.length; aa++) {
                                                var nodeP = 'node' + jtem.data[0].node[aa].type;
                                                team_one += '<div class="mt10 f22 line_center c-999"><span class="name single-ellipsis">' + jtem.data[0].node[aa].player_name + '</span><span class="node ' + nodeP + ' ml10"></span></div>'
                                            }
                                        }
                                        var team_two = '';
                                        if (isDefine(jtem.data[1].node)) {
                                            for (var aa = 0; aa < jtem.data[1].node.length; aa++) {
                                                var nodeP = 'node' + jtem.data[1].node[aa].type;
                                                team_two += '<div class="mt10 f22 line_center c-999"><span class="node ' + nodeP + ' mr10"></span><span class="name single-ellipsis">' + jtem.data[1].node[aa].player_name + '</span></div>'
                                            }
                                        }
                                        var teamParam1 = {"team_id": jtem.data[0].team_id};//左侧队伍id
                                        var teamParam2 = {"team_id": jtem.data[1].team_id};//右侧队伍id
                                        var matchParam = {"match_id": jtem.id};//比赛id
                                        matchHtml += '<li id="'+childId+'" class="match_li flex_center ">' +
                                            '            <div class="match_team f26 pt30" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                                            '                <div class="match_team_img bg-cover"' +
                                            '                     style="background: url(' + ajaxUrl + jtem.data[0].team_path + ') center no-repeat;"></div>' +
                                            '                <div class="mt20 pd10 t-c">' + jtem.data[0].team_title + '</div>' + team_one +
                                            '            </div>' +
                                            '            <div class="match_details" tapmode onclick=\'commonUrl("match_football",' + jsonChange(matchParam) + ')\'>' +
                                            '                <div class="b f32">' + jtem.title + '</div>' +
                                            '                <div class="mt10 c-999 f24">' + jtem.start_date + ' ' + jtem.address + '</div>' + statusHtml +
                                            '            </div>' +
                                            '            <div class="match_team f26 pt30" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                                            '                <div class="match_team_img bg-cover"' +
                                            '                     style="background: url(' + ajaxUrl + jtem.data[1].team_path + ') center no-repeat;"></div>' +
                                            '                <div class="mt20 pd10 t-c">' + jtem.data[1].team_title + '</div>' + team_two +
                                            '            </div>' +
                                            '        </li>';

                                    }

                                } else {

                                    var statusHtml = '';

                                    if (jtem.status == 1) {
                                        //status 1是未开始，2是进行中，3是已结束
                                        var bellHtml = '';

                                        if (jtem.remind_status == 2) {
                                            bellHtml = ' <div class="bell-status f26" tapmode onclick=\'remind(' + jtem.id + ',this,event)\'>' +
                                                '                    <img class="icon-bell bell-off" src="../../icon/icon-bell.png"/>' +
                                                '                    <img class="icon-bell bell-on" src="../../icon/icon-bell-on.png"/>' +
                                                '          </div>'
                                        } else {
                                            bellHtml = ' <div class="bell-status on f26" tapmode onclick=\'remind(' + jtem.id + ',this,event)\'>' +
                                                '                    <img class="icon-bell bell-off" src="../../icon/icon-bell.png"/>' +
                                                '                    <img class="icon-bell bell-on" src="../../icon/icon-bell-on.png"/>' +
                                                '          </div>'
                                        }

                                        statusHtml = '<div class="match_team" style="width: 1.3rem;margin-left: 0.2rem;">' + bellHtml +
                                            '                    <div class="match_tips1 end mt10 c-fff"><i class="icon-live mr10"></i>未开始</div>' +
                                            '                </div>'


                                    }  else if (jtem.status == 2) {
                                        statusHtml = '<div class="match_tips1 being mt10 c-fff ml20">进行中</div>';

                                    } else if (jtem.status == 3) {
                                        statusHtml = '<div class="match_tips1 end mt10 c-fff ml20">已结束</div>';

                                    } else if (jtem.status == 4) {
                                        statusHtml = '<div class="match_tips1 being mt10 c-fff ml20"><i class="icon-live mr10"></i>直播中</div>';

                                    } else if (jtem.status == 5) {
                                        statusHtml = '<div class="match_tips1 being mt10 c-fff ml20"><i class="icon-live mr10"></i>视频回放</div>';

                                    }

                                    var matchParam = {"match_id": jtem.id}
                                    matchHtml += '<li id="'+childId+'" class="match_li line_center" style="padding: 0.1rem 0.1rem;" tapmode onclick=\'commonUrl("team_match_detail",' + jsonChange(matchParam) + ')\'>' +
                                        '            <div class="match_team f26" style="width: calc((100% - 4rem) / 2);">' +
                                        '                <div class="match_team_img bg-cover"' +
                                        '                     style="background: url(' + ajaxUrl + jtem.icon_path + ') center no-repeat;"></div>' +
                                        '            </div>' +
                                        '            <div class="match_details" style="width: 4rem;">' +
                                        '                <div class="b f32" style="width: 100%;">' + jtem.title + '</div>' +
                                        '                <div class="mt10 c-999 f24  t-l"  style="width: 100%;">' + jtem.start_date + ' ' + jtem.address + '</div>' +
                                        '            </div>' + statusHtml +
                                        '        </li>'

                                }

                            })

                            console.log(matchHtml)
                            if (secondType == 1) {
                                // console.log(22222222222222222222222222)
                                $("#mainMatch .getlist").eq(navIndex).html(matchHtml);
                                // secondType = 3;
                                matchHtml = '';
                                getMatchIndex(3,'down')
                                console.log(pageDown)
                            }else if(secondType == 3){
                                sType = true;
                            }
                        }

                    } else {
                        if (secondType == 1) {
                            var todayHtml = '';
                            todayHtml += '<li class="pt10 pb10 f24 c-999 t-c">' + item.date_time + '</li>';
                            todayHtml += '<li class="line_center"><p class="f24 t-c pt30 pb30" style="width: 100%; color: #cccccc;">今日暂无比赛数据</p></li>';
                            $("#mainMatch .getlist").eq(navIndex).html(todayHtml);
                            /*secondType = 3;*/
                            getMatchIndex(3,'down')
                            console.log(pageDown)
                        }
                    }

                    if(tipsNum == 0){
                        pop.notice('上下滑动可查看更多',3)
                        tipsNum++;
                    }


                })

                if (secondType == 3) {
                    if(sType){
                        $("#mainMatch .getlist").eq(navIndex).append(matchHtml);
                        pageDown++;
                        pullDown = true;
                        $("#mainMatchChild .swiper-slide").eq(navIndex).attr('data-dflag',true)
                        $("#mainMatchChild .swiper-slide").eq(navIndex).attr('data-downpage',pageDown)
                    }

                } else if (secondType == 2) {
                    console.log(navIndex)
                    $("#mainMatch .getlist").eq(navIndex).find('li').eq(0).before(matchHtml)
                    if(isDefine(matchHtml)){
                        var flag_id = '#'+flag;
                        console.log(flag_id)
                        console.log(jsonChange($(flag_id).offset()))
                        console.log($(flag_id).offset().top)
                        $("#mainMatch .mescroll").eq(navIndex).animate({ scrollTop: $(flag_id).offset().top},0);
                        pageUp++;
                        pullUp = true;
                        $("#mainMatchChild .swiper-slide").eq(navIndex).attr('data-uflag',true)
                        $("#mainMatchChild .swiper-slide").eq(navIndex).attr('data-uppage',pageUp)
                    }

                }

                console.log("pullUp："+pullUp)
                console.log("pullDown："+pullDown)
            } else {
                if (secondType == 3) {
                    $("#mainMatchChild .swiper-slide").eq(navIndex).attr('data-dflag',false)
                    pullDown = false;
                } else if (secondType == 2) {
                    $("#mainMatchChild .swiper-slide").eq(navIndex).attr('data-uflag',false)
                    pullUp = false;
                }
                setTimeout(function () {
                    if (secondType == 3) {
                        // pop.notice('暂无近期比赛')
                        if(pageDown == 1){
                            pop.notice('下拉可查看更多比赛',3)
                        }
                        $("#mainMatch .getlist").eq(navIndex).append('<li class="line_center"><p class="f24 t-c pt30 pb30" style="width: 100%; color: #cccccc;">没有更多了</p></li>');
                    } else if (secondType == 2) {
                        // pop.notice('暂无之前比赛')
                        $("#mainMatch .getlist").eq(navIndex).find('li').eq(0).before('<li class="line_center"><p class="f24 t-c pt30 pb30" style="width: 100%; color: #cccccc;">没有更多了</p></li>');
                    }

                    console.log("pullUp："+pullUp)
                    console.log("pullDown："+pullDown)
                },10)

                // $("#match_list").html(noData);
            }
            // mescroll.endErr();
            endErr(navIndex)
        }, function (error) {
            pop.notice(error.msg);
            // mescroll.endErr();
            endErr(navIndex)
        })

    }


    //开启关闭赛事提醒
    function remind(id, that, event) {
        var match_id = id;
        event.stopPropagation();
        if ($(that).hasClass('on')) {
            $(that).removeClass('on');
            addRemind(2, match_id)
        } else {
            $(that).addClass('on');
            addRemind(1, match_id)
        }

    }

    //关注赛事提醒
    function addRemind(type, match_id) {
        var param = {
            token: $api.getStorage('token'),
            match_id: match_id,
            type: type,
        }
        getAjax(Interface.set_remind, param, function (res) {
            if (type == 1) {
                pop.notice('已开启提醒')
            } else {
                pop.notice('已关闭提醒')
            }
        }, function (error) {
            pop.notice(error.msg)
        })
    }

    $(".match_nav_li").on('click', 'li', function () {
        $(".match_nav_li li").removeClass("on");
        $(this).addClass("on");

        category_id = $(this).attr('data-id');
        // secondType = 1;
        pageUp = 1;
        pageDown = 1;
        pullUp = true;
        pullDown = false;
        sType = false;
        // $("#match_list").html('');
        console.log('111111111111111============'+pullDown)
        getMatchIndex(1)

        // $(".page_box").removeClass("on");
        // $(".page_box").eq($(this).index()).addClass("on");
    })


</script>
